<%@page import="entity.Member"%>
<%@page import="dao.MemberDao"%>
<%@page import="service.FindDiscuss"%>
<%@page import="entity.Discuss"%>
<%@page import="java.util.List"%>
<%@page import="entity.Book"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page errorPage="error.jsp" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" charset="utf-8" />
        <style>
            body{
                background: url(img/Bookbg.jpg);
                background-size: cover;
            }
        </style>
    </head>
    <body>
        <div class="container">
        <%
            Book book=(Book)request.getAttribute("book");
            
        %>
        <h1 style="margin-left: 10px; margin-top:60px;"><%=book.getBookName()%></h1>
        <div style="position:absolute;font-size: 20px;left:1000px;top:100px"><a href="index" class="btn btn-warning">返回首页</a></div>
        <div style="margin-left: 10px">
            <div>
                <img  style="border-radius: 10px" src="img/<%=book.getCover()%>" width="220px" height="300px" alt="<%=book.getBookName()%>">
            </div>
            <div style="width: 300px;height:250px;position:absolute;left:700px;top:150px" >
                <p>编号：<%=book.getId()%></p>
                <p>作者：<%=book.getAuthor()%></p>
                <p>出版日期：<%=book.getPublishDate()%></p>
                <p>出版社：<%=book.getPublishHouse()%></p>
                <p>类型：<%=book.getType()%></p>
            </div>
            <br>
            <div style="width:400px;word-wrap: break-word">
                <p>简介：<%=book.getIntroduction()%></p>
                <p style="font-size: 18px">评分：<%=book.getMark()%>分</p>
            </div>
            <div style="width:650px;word-wrap: break-word"> 
                <p style="font-size: 18px">评论：<a href="discuss.jsp?bookid=<%=book.getId()%>" class="btn btn-success">我要评论</a></p>
                <%
                    List<Discuss> list=new FindDiscuss().findDiscussByBookId(book.getId());
                    for(Discuss discuss:list){
                        Member member=new MemberDao().getMemberById(discuss.getMemberId());

                %>
                <p style="font-size: 18px"><%=member.getName()%>:<%=discuss.getComment()%>
                <%
                    if(session.getAttribute("isLogin")!=null){
                        String name=(String)session.getAttribute("username");
                        Member member1=new MemberDao().getMemberByName(name);
                        if(member1.getId()==member.getId()){
                %>
                <a href="dds?id=<%=discuss.getId()%>&bookid=<%=book.getId()%>">删除</a>
                <%
                        }
                }
                %>
                </p>
                <%
                    }
                %>
            </div>
        </div>
        
        <h1 style="position: absolute;left:900px;top:150px">单价：<%=book.getPrice()%>元</h1>
        <div style="position: absolute;left:900px;top:250px">
            <a href="cas?bookid=<%=book.getId()%>" class="btn btn-danger">加入购物车</a><br><br>
            <a href="Buy.jsp?bookid=<%=book.getId()%>" class="btn btn-info">立刻购买</a><br><br>
            <a href="cs?bookid=<%=book.getId()%>" class="btn btn-primary">收藏</a><br>
        </div>
        </div>
    </body>
</html>
